package entity

import (
	"time"

	"shqsoft.cn/pasnj/base"
)

//币种
type CUCY struct {
	ID   int    `gorm:"primary_key;column:CYNO"`
	Name string `gorm:"column:CYNM;size:20"`
}

//TableName 币种
func (CUCY) TableName() string {
	return "T_BASE_CUCY"
}

//存期
type PERD struct {
	ID   int    `gorm:"primary_key;column:RDNO"`
	Name string `gorm:"column:RDNM;size:20"`
}

//TableName 存期
func (PERD) TableName() string {
	return "T_CONF_PERD"
}

//卡号
type CARD struct {
	ID int    `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	NO string `gorm:"column:CDNO;size:20"`
}

//TableName 卡号
func (CARD) TableName() string {
	return "T_INDI_CARD"
}

//t_indi_acco
type Dszhrd struct {
	ID             int          `gorm:"AUTO_INCREMENT;primary_key;column:ID"` //自增序号
	ACNO           string       `gorm:"column:ACNO;"`                         //账号
	BANO           string       `gorm:"column:BANO;"`                         //子账号
	CUID           int          `gorm:"column:CUID;"`                         //客户id
	CUNM           string       `gorm:"column:CUNM;"`                         //客户名称
	OPDT           string       `gorm:"column:OPDT;"`                         //开户日期
	ACBL           float64      `gorm:"column:ACBL;"`                         //余额
	VLDT           time.Time    `gorm:"column:VLDT;type:date;"`               //起息日
	MADT           time.Time    `gorm:"column:MADT;type:date;"`               //到期日
	CLDT           time.Time    `gorm:"column:CLDT;type:date;"`               //销户日
	INRT           float64      `gorm:"column:INRT;"`                         //利率
	IDNO           string       `gorm:"column:IDNO;"`                         //证件号码
	CUCYID         int          `gorm:"column:CYNO"`                          //币种
	CUCY           CUCY         `gorm:"ForeignKey:CUCYID"`                    //
	PERDID         int          `gorm:"column:PERD"`                          //存期
	PERD           PERD         `gorm:"ForeignKey:PERDID"`                    //
	OrganizationID int          `gorm:"column:UTID"`                          //机构
	Organization   Organization `gorm:"ForeignKey:OrganizationID"`            //
	CARDID         int          `gorm:"column:CAID"`                          //卡号
	CARD           CARD         `gorm:"ForeignKey:CARDID"`                    //
	ISDIVI         bool         `gorm:"column:ISDIVI;"`                       //是否认定
	ISXJK          bool         `gorm:"column:ISXJK;"`                        //是否认定
	ISMR           bool         `gorm:"column:ISMR;"`                         //是否认定
}

//TableName User用户表名
func (Dszhrd) TableName() string {
	return "T_INDI_ACCO"
}

func CUCYEF() base.EntityFunc {
	return func() interface{} {
		entity := CUCY{}
		return &entity
	}
}
func CUCYESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []CUCY
		return &entities
	}
}

func PERDEF() base.EntityFunc {
	return func() interface{} {
		entity := PERD{}
		return &entity
	}
}
func PERDESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []PERD
		return &entities
	}
}

func CARDEF() base.EntityFunc {
	return func() interface{} {
		entity := CARD{}
		return &entity
	}
}
func CARDESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []CARD
		return &entities
	}
}

func DszhrdEF() base.EntityFunc {
	return func() interface{} {
		entity := Dszhrd{}
		return &entity
	}
}
func DszhrdESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []Dszhrd
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("CUCY", base.NewDefaultDao(CUCYEF(), CUCYESF(), nil))
	base.DaoPoolObj.Put("PERD", base.NewDefaultDao(PERDEF(), PERDESF(), nil))
	base.DaoPoolObj.Put("CARD", base.NewDefaultDao(CARDEF(), CARDESF(), nil))
	relationship := []string{"Organization", "CUCY", "PERD", "CARD"}
	dao := base.NewDefaultDao(DszhrdEF(), DszhrdESF(), relationship)
	filter := base.DefaultFilter{
		FilterColName: "UTID",
	}
	dao.Fileter = &filter
	base.DaoPoolObj.Put("Dszhrd", dao)
}
